Event Handler Chain
Event handlers are organized in a chain. The link between two handlers is the method GetNextHandler. Most of the methods defined by EvtHandler are implemented by forwarding the message to the next handler. Subclasses that override a method of EvtHandler should always call the inherited method in order to preserve the chain.
As an example, the VObject tree (see class VObject) of a window contains several event handler chains. Each chain starts at a leaf of the tree, follows the hierarchy upwards and either ends at the window or the window links it to another handler, usually a Document. Another example is the event handler chain View -> Document -> Application.
The event handler chain serves several purposes: Controlling, Command and Menu handling.
Controlling
Input events from the keyboard and the mouse are distributed from the root of a VObject tree to the leafs. The leafs can generate additional, application-specific events. Such events are forwarded along the event handler chain via the method Control. For example, things like buttons use Control to inform the "controlling" Dialog about a selection event (see method Button::DoOnItem, method ActionButton::Control and method Dialog::Control).
The counterpart of Control is the method SendDown (in older ET++ versions called DownControl). SendDown does not follow the event handler chain but allows a VObject to communicate with other objects that are lower in the VObject tree. By means of this method a VObject can request one or several objects down in the tree to do certain things or return some data. For example, the class OneOfCluster uses SendDown to switch one of its contained buttons on and all others off. The method DialogView::Control calls SendDown to assign the keyboard focus.
Commands (see also cookbook Commands)
The method VObject::DispatchEvents distributes mouse and keyboard events to the corresponding Do...Command methods. The command object returned by these methods is passed along the event handler chain through the method PerformCommand until the end of the chain is reached or an EvtHandler has overridden PerformCommand and executes the command. This is usually done by a Document (see the method Document::PerformCommand).
Menus (see also cookbook Menus)
Whenever the right mouse button is pressed over a VObject, then the a popup menu is shown. Four methods of EvtHandler deal with that menu: method GetMenu, method DoCreateMenu, method DoSetupMenu and method DoMenuCommand. By default, all methods are passed along the event handler chain so that several handlers may take part in the creation and setup of the menu as well as in the handling of menu commands. The method VObject::DoRightButtonDownCommand calls the menu handling methods in the following order:
GetMenu passed to the next handlers until one returns a menu DoCreateMenu called once for new menus; allows to add menu items and submenus DoSetupMenu enable/disable menu items and update their text DoMenuCommand handle the menu command selected by the user
classes are always derived from EvtHandler.
class EvtHandler
is never reused directly.
class EvtHandler is abstract.
class EvtHandler contains 12 methods.
Application Framework